home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Tool Chest / Interfaces & Libraries / Interfaces / CIncludes / Lists.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-06  |  11.7 KB  |  326 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        Lists.h
  3.  
  4.      Contains:    List Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.1 in “MPW Latest” on ETO #18
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __LISTS__
  21. #define __LISTS__
  22.  
  23.  
  24. #ifndef __TYPES__
  25. #include <Types.h>
  26. #endif
  27. /*    #include <ConditionalMacros.h>                                */
  28.  
  29. #ifndef __CONTROLS__
  30. #include <Controls.h>
  31. #endif
  32. /*    #include <Quickdraw.h>                                        */
  33. /*        #include <MixedMode.h>                                    */
  34. /*        #include <QuickdrawText.h>                                */
  35. /*    #include <Menus.h>                                            */
  36. /*        #include <Memory.h>                                        */
  37.  
  38. #ifndef __MEMORY__
  39. #include <Memory.h>
  40. #endif
  41.  
  42. #ifdef __cplusplus
  43. extern "C" {
  44. #endif
  45.  
  46. #if PRAGMA_ALIGN_SUPPORTED
  47. #pragma options align=mac68k
  48. #endif
  49.  
  50. #if PRAGMA_IMPORT_SUPPORTED
  51. #pragma import on
  52. #endif
  53.  
  54. #ifndef STRICT_LISTS
  55. #define STRICT_LISTS 0
  56. #endif
  57. #if !STRICT_LISTS
  58.  
  59. enum {
  60.     lDoVAutoscroll                = 2,
  61.     lDoHAutoscroll                = 1,
  62.     lOnlyOne                    = -128,
  63.     lExtendDrag                    = 64,
  64.     lNoDisjoint                    = 32,
  65.     lNoExtend                    = 16,
  66.     lNoRect                        = 8,
  67.     lUseSense                    = 4,
  68.     lNoNilHilite                = 2
  69. };
  70.  
  71. enum {
  72.     lDoVAutoscrollBit            = 1,
  73.     lDoHAutoscrollBit            = 0,
  74.     lOnlyOneBit                    = 7,
  75.     lExtendDragBit                = 6,
  76.     lNoDisjointBit                = 5,
  77.     lNoExtendBit                = 4,
  78.     lNoRectBit                    = 3,
  79.     lUseSenseBit                = 2,
  80.     lNoNilHiliteBit                = 1
  81. };
  82.  
  83. #endif
  84.  
  85. enum {
  86.     lInitMsg                    = 0,
  87.     lDrawMsg                    = 1,
  88.     lHiliteMsg                    = 2,
  89.     lCloseMsg                    = 3
  90. };
  91.  
  92. #if STRICT_LISTS
  93. typedef struct OpaqueListRef *ListRef;
  94.  
  95. typedef ListRef ListHandle;
  96.  
  97. #else
  98. typedef struct ListRec ListRec, *ListPtr, **ListHandle;
  99.  
  100. typedef ListHandle ListRef;
  101.  
  102. #endif
  103. typedef Point Cell;
  104.  
  105. typedef Rect ListBounds;
  106.  
  107. typedef char DataArray[32001];
  108.  
  109. typedef char *DataPtr, **DataHandle;
  110.  
  111. typedef pascal short (*ListSearchProcPtr)(Ptr aPtr, Ptr bPtr, short aLen, short bLen);
  112. /*
  113.         ListClickLoopProcPtr uses register based parameters on the 68k and cannot
  114.         be written in or called from a high-level language without the help of
  115.         mixed mode or assembly glue.
  116.  
  117.             typedef pascal Boolean (*ListClickLoopProcPtr)(void);
  118.  
  119.         In:
  120.          =>                 .?
  121.         Out:
  122.          <= return value    D0.B
  123. */
  124.  
  125. #if GENERATINGCFM
  126. typedef UniversalProcPtr ListSearchUPP;
  127. typedef UniversalProcPtr ListClickLoopUPP;
  128. #else
  129. typedef ListSearchProcPtr ListSearchUPP;
  130. typedef Register68kProcPtr ListClickLoopUPP;
  131. #endif
  132.  
  133. #if !STRICT_LISTS
  134. struct ListRec {
  135.     Rect                            rView;
  136.     GrafPtr                            port;
  137.     Point                            indent;
  138.     Point                            cellSize;
  139.     ListBounds                        visible;
  140.     ControlRef                        vScroll;
  141.     ControlRef                        hScroll;
  142.     SInt8                            selFlags;
  143.     Boolean                            lActive;
  144.     SInt8                            lReserved;
  145.     SInt8                            listFlags;
  146.     long                            clikTime;
  147.     Point                            clikLoc;
  148.     Point                            mouseLoc;
  149.     ListClickLoopUPP                lClickLoop;
  150.     Cell                            lastClick;
  151.     long                            refCon;
  152.     Handle                            listDefProc;
  153.     Handle                            userHandle;
  154.     ListBounds                        dataBounds;
  155.     DataHandle                        cells;
  156.     short                            maxIndex;
  157.     short                            cellArray[1];
  158. };
  159. #endif
  160. typedef pascal void (*ListDefProcPtr)(short lMessage, Boolean lSelect, Rect *lRect, Cell lCell, short lDataOffset, short lDataLen, ListRef lHandle);
  161. typedef pascal void (*ListCellDrawProcPtr)(short lMessage, Boolean lSelect, Rect *lRect, Cell lCell, void *dataPtr, short lDataLen, ListRef lHandle);
  162.  
  163. #if GENERATINGCFM
  164. typedef UniversalProcPtr ListDefUPP;
  165. typedef UniversalProcPtr ListCellDrawUPP;
  166. #else
  167. typedef ListDefProcPtr ListDefUPP;
  168. typedef ListCellDrawProcPtr ListCellDrawUPP;
  169. #endif
  170.  
  171. enum {
  172.     uppListSearchProcInfo = kPascalStackBased
  173.          | RESULT_SIZE(SIZE_CODE(sizeof(short)))
  174.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(Ptr)))
  175.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Ptr)))
  176.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(short)))
  177.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(short))),
  178.     uppListClickLoopProcInfo = kRegisterBased
  179.          | RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
  180.          | REGISTER_RESULT_LOCATION(kRegisterD0),
  181.     uppListDefProcInfo = kPascalStackBased
  182.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short)))
  183.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Boolean)))
  184.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Rect*)))
  185.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(Cell)))
  186.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(short)))
  187.          | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(short)))
  188.          | STACK_ROUTINE_PARAMETER(7, SIZE_CODE(sizeof(ListRef))),
  189.     uppListCellDrawProcInfo = kPascalStackBased
  190.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(short)))
  191.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(Boolean)))
  192.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Rect*)))
  193.          | STACK_ROUTINE_PARAMETER(4, SIZE_CODE(sizeof(Cell)))
  194.          | STACK_ROUTINE_PARAMETER(5, SIZE_CODE(sizeof(void*)))
  195.          | STACK_ROUTINE_PARAMETER(6, SIZE_CODE(sizeof(short)))
  196.          | STACK_ROUTINE_PARAMETER(7, SIZE_CODE(sizeof(ListRef)))
  197. };
  198.  
  199. #if GENERATINGCFM
  200. #define NewListSearchProc(userRoutine)        \
  201.         (ListSearchUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppListSearchProcInfo, GetCurrentArchitecture())
  202. #define NewListClickLoopProc(userRoutine)        \
  203.         (ListClickLoopUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppListClickLoopProcInfo, GetCurrentArchitecture())
  204. #define NewListDefProc(userRoutine)        \
  205.         (ListDefUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppListDefProcInfo, GetCurrentArchitecture())
  206. #define NewListCellDrawProc(userRoutine)        \
  207.         (ListCellDrawUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppListCellDrawProcInfo, GetCurrentArchitecture())
  208. #else
  209. #define NewListSearchProc(userRoutine)        \
  210.         ((ListSearchUPP) (userRoutine))
  211. #define NewListClickLoopProc(userRoutine)        \
  212.         ((ListClickLoopUPP) (userRoutine))
  213. #define NewListDefProc(userRoutine)        \
  214.         ((ListDefUPP) (userRoutine))
  215. #define NewListCellDrawProc(userRoutine)        \
  216.         ((ListCellDrawUPP) (userRoutine))
  217. #endif
  218.  
  219. #if GENERATINGCFM
  220. #define CallListSearchProc(userRoutine, aPtr, bPtr, aLen, bLen)        \
  221.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppListSearchProcInfo, (aPtr), (bPtr), (aLen), (bLen))
  222. #define CallListClickLoopProc(userRoutine)        \
  223.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppListClickLoopProcInfo)
  224. #define CallListDefProc(userRoutine, lMessage, lSelect, lRect, lCell, lDataOffset, lDataLen, lHandle)        \
  225.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppListDefProcInfo, (lMessage), (lSelect), (lRect), (lCell), (lDataOffset), (lDataLen), (lHandle))
  226. #define CallListCellDrawProc(userRoutine, lMessage, lSelect, lRect, lCell, dataPtr, lDataLen, lHandle)        \
  227.         CallUniversalProc((UniversalProcPtr)(userRoutine), uppListCellDrawProcInfo, (lMessage), (lSelect), (lRect), (lCell), (dataPtr), (lDataLen), (lHandle))
  228. #else
  229. #define CallListSearchProc(userRoutine, aPtr, bPtr, aLen, bLen)        \
  230.         (*(userRoutine))((aPtr), (bPtr), (aLen), (bLen))
  231. /* (*ListClickLoopProcPtr) cannot be called from a high-level language without the Mixed Mode Manager */
  232. #define CallListDefProc(userRoutine, lMessage, lSelect, lRect, lCell, lDataOffset, lDataLen, lHandle)        \
  233.         (*(userRoutine))((lMessage), (lSelect), (lRect), (lCell), (lDataOffset), (lDataLen), (lHandle))
  234. #define CallListCellDrawProc(userRoutine, lMessage, lSelect, lRect, lCell, dataPtr, lDataLen, lHandle)        \
  235.         (*(userRoutine))((lMessage), (lSelect), (lRect), (lCell), (dataPtr), (lDataLen), (lHandle))
  236. #endif
  237.  
  238. extern pascal ListRef LNew(const Rect *rView, const ListBounds *dataBounds, Point cSize, short theProc, WindowRef theWindow, Boolean drawIt, Boolean hasGrow, Boolean scrollHoriz, Boolean scrollVert)
  239.  THREEWORDINLINE(0x3F3C, 0x0044, 0xA9E7);
  240. extern pascal void LDispose(ListRef lHandle)
  241.  THREEWORDINLINE(0x3F3C, 0x0028, 0xA9E7);
  242. extern pascal short LAddColumn(short count, short colNum, ListRef lHandle)
  243.  THREEWORDINLINE(0x3F3C, 0x0004, 0xA9E7);
  244. extern pascal short LAddRow(short count, short rowNum, ListRef lHandle)
  245.  THREEWORDINLINE(0x3F3C, 0x0008, 0xA9E7);
  246. extern pascal void LDelColumn(short count, short colNum, ListRef lHandle)
  247.  THREEWORDINLINE(0x3F3C, 0x0020, 0xA9E7);
  248. extern pascal void LDelRow(short count, short rowNum, ListRef lHandle)
  249.  THREEWORDINLINE(0x3F3C, 0x0024, 0xA9E7);
  250. extern pascal Boolean LGetSelect(Boolean next, Cell *theCell, ListRef lHandle)
  251.  THREEWORDINLINE(0x3F3C, 0x003C, 0xA9E7);
  252. extern pascal Cell LLastClick(ListRef lHandle)
  253.  THREEWORDINLINE(0x3F3C, 0x0040, 0xA9E7);
  254. extern pascal Boolean LNextCell(Boolean hNext, Boolean vNext, Cell *theCell, ListRef lHandle)
  255.  THREEWORDINLINE(0x3F3C, 0x0048, 0xA9E7);
  256. extern pascal Boolean LSearch(const void *dataPtr, short dataLen, ListSearchUPP searchProc, Cell *theCell, ListRef lHandle)
  257.  THREEWORDINLINE(0x3F3C, 0x0054, 0xA9E7);
  258. extern pascal void LSize(short listWidth, short listHeight, ListRef lHandle)
  259.  THREEWORDINLINE(0x3F3C, 0x0060, 0xA9E7);
  260. extern pascal void LSetDrawingMode(Boolean drawIt, ListRef lHandle)
  261.  THREEWORDINLINE(0x3F3C, 0x002C, 0xA9E7);
  262. extern pascal void LScroll(short dCols, short dRows, ListRef lHandle)
  263.  THREEWORDINLINE(0x3F3C, 0x0050, 0xA9E7);
  264. extern pascal void LAutoScroll(ListRef lHandle)
  265.  THREEWORDINLINE(0x3F3C, 0x0010, 0xA9E7);
  266. extern pascal void LUpdate(RgnHandle theRgn, ListRef lHandle)
  267.  THREEWORDINLINE(0x3F3C, 0x0064, 0xA9E7);
  268. extern pascal void LActivate(Boolean act, ListRef lHandle)
  269.  TWOWORDINLINE(0x4267, 0xA9E7);
  270. extern pascal void LCellSize(Point cSize, ListRef lHandle)
  271.  THREEWORDINLINE(0x3F3C, 0x0014, 0xA9E7);
  272. extern pascal Boolean LClick(Point pt, short modifiers, ListRef lHandle)
  273.  THREEWORDINLINE(0x3F3C, 0x0018, 0xA9E7);
  274. extern pascal void LAddToCell(const void *dataPtr, short dataLen, Cell theCell, ListRef lHandle)
  275.  THREEWORDINLINE(0x3F3C, 0x000C, 0xA9E7);
  276. extern pascal void LClrCell(Cell theCell, ListRef lHandle)
  277.  THREEWORDINLINE(0x3F3C, 0x001C, 0xA9E7);
  278. extern pascal void LGetCell(void *dataPtr, short *dataLen, Cell theCell, ListRef lHandle)
  279.  THREEWORDINLINE(0x3F3C, 0x0038, 0xA9E7);
  280. extern pascal void LRect(Rect *cellRect, Cell theCell, ListRef lHandle)
  281.  THREEWORDINLINE(0x3F3C, 0x004C, 0xA9E7);
  282. extern pascal void LSetCell(const void *dataPtr, short dataLen, Cell theCell, ListRef lHandle)
  283.  THREEWORDINLINE(0x3F3C, 0x0058, 0xA9E7);
  284. extern pascal void LSetSelect(Boolean setIt, Cell theCell, ListRef lHandle)
  285.  THREEWORDINLINE(0x3F3C, 0x005C, 0xA9E7);
  286. extern pascal void LDraw(Cell theCell, ListRef lHandle)
  287.  THREEWORDINLINE(0x3F3C, 0x0030, 0xA9E7);
  288. extern pascal void LGetCellDataLocation(short *offset, short *len, Cell theCell, ListRef lHandle)
  289.  THREEWORDINLINE(0x3F3C, 0x0034, 0xA9E7);
  290. #if CGLUESUPPORTED
  291. extern void laddtocell(Ptr dataPtr, short dataLen, Cell *theCell, ListRef lHandle);
  292. extern void lclrcell(Cell *theCell, ListRef lHandle);
  293. extern void lgetcelldatalocation(short *offset, short *len, Cell *theCell, ListRef lHandle);
  294. extern void lgetcell(Ptr dataPtr, short *dataLen, Cell *theCell, ListRef lHandle);
  295. extern ListRef lnew(Rect *rView, ListBounds *dataBounds, Point *cSize, short theProc, WindowRef theWindow, Boolean drawIt, Boolean hasGrow, Boolean scrollHoriz, Boolean scrollVert);
  296. extern void lrect(Rect *cellRect, Cell *theCell, ListRef lHandle);
  297. extern void lsetcell(Ptr dataPtr, short dataLen, Cell *theCell, ListRef lHandle);
  298. extern void lsetselect(Boolean setIt, Cell *theCell, ListRef lHandle);
  299. extern void ldraw(Cell *theCell, ListRef lHandle);
  300. extern Boolean lclick(Point *pt, short modifiers, ListRef lHandle);
  301. extern void lcellsize(Point *cSize, ListRef lHandle);
  302. #endif
  303. #if OLDROUTINENAMES
  304. #define LDoDraw(drawIt, lHandle) LSetDrawingMode(drawIt, lHandle)
  305. #define LFind(offset, len, theCell, lHandle)  \
  306.     LGetCellDataLocation(offset, len, theCell, lHandle)
  307. #if CGLUESUPPORTED
  308. #define lfind(offset, len, theCell, lHandle)  \
  309.     lgetcelldatalocation(offset, len, theCell, lHandle)
  310. #endif
  311. #endif
  312.  
  313. #if PRAGMA_IMPORT_SUPPORTED
  314. #pragma import off
  315. #endif
  316.  
  317. #if PRAGMA_ALIGN_SUPPORTED
  318. #pragma options align=reset
  319. #endif
  320.  
  321. #ifdef __cplusplus
  322. }
  323. #endif
  324.  
  325. #endif /* __LISTS__ */
  326.